
import entity.Signon;
import mapper.SignonMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.testng.annotations.Test;

import java.io.IOException;
import java.io.InputStream;

public class insert {
    @Test
    void insert() throws IOException {
        String resource="mybatis-config.xml";
        InputStream inputStream= Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactoryBuilder=new
                SqlSessionFactoryBuilder().build(inputStream);
        try (SqlSession session=sqlSessionFactoryBuilder.openSession(true)){
            SignonMapper signonMapper=session.getMapper(SignonMapper.class);
            Signon signon=new Signon("aaa","xxx","123");
            int result=signonMapper.insertSignon(signon);
            System.out.println(result);
            System.out.println("要插入的行"+signon.getId());
        }
    }
}
